package com.cloudeasy.server.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloudeasy.server.mapper.PermissionMapper;
import com.cloudeasy.server.po.Permission;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionService extends ServiceImpl<PermissionMapper, Permission> {

    /**
     * 获取权限
     *
     * @param permissionIds 权限Id列表
     * @return {@link List<Permission>}
     */
    List<Permission> list(List<String> permissionIds) {
        QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id", permissionIds)
                .or(permissionQueryWrapper -> permissionQueryWrapper.in("parent_id", permissionIds));
        return this.list(queryWrapper);
    }
}
